/*
 * This file is part of Catfish.
 * Copyright (C) 2010 Namazu Studios LLC
 * 
 * Catfish is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of 
 * the License, or (at your option) any later version.
 * 
 * Catfish is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with Catfish.  If not, please visit:
 *  
 * http://www.gnu.org/licenses/
 *  
 */
package com.namazustudios.catfish;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Transaction;

/**
 * An interface to a Unmarshaller. Instances of this class unmarshall full
 * object graphs from the datastore. This is expose to the public API such that
 * it can be used to unmarshall the result of queries.
 * 
 * @author patrick
 * 
 */
public interface Unmarshaller {

	/**
	 * Unmarshalls the given Entity into an object. The Entity may have
	 * references to child objects.
	 * 
	 * @param entity
	 *            the entity to deserialize
	 * @return the fully unmarshalled object
	 */
	public abstract Object unmarshall(Entity entity);

	/**
	 * Unmarshalls the entity into the given object.
	 * 
	 * @param destination
	 * @param entity
	 * @return
	 */
	public abstract void unmarshall(Object destination, Entity entity);

	/**
	 * Unmarshalls the given Entity into an object. The Entity may have
	 * references to child objects.
	 * 
	 * @param entity
	 *            the entity to deserialize
	 * @return the fully unmarshalled object
	 */
	public abstract Object unmarshall(Transaction transaction, Entity entity);

	/**
	 * Unmarshalls the entity into the given object.
	 * 
	 * @param destination
	 * @param entity
	 * @return
	 */
	public abstract void unmarshall(Object destination, Transaction transaction, Entity entity);

}